package murphyhan;

import java.util.ArrayList;

public class Path {
	ArrayList points = new ArrayList();

	public void add(GLatLng point) {
		points.add(point);
	}

	public GLatLng getLstPoint() {

		return points.size() > 0 ? (GLatLng) points.get(points.size() - 1)
				: null;
	}

	public int getPointsCount(int divide) {
		return points.size() / divide;
	}

	public String getPoints(int divide) {
		int count = 0;
		StringBuffer re = new StringBuffer();
		re.append("[");
		for (int i = 0, j = points.size(); i < j; i++) {
			if (i == 0 || i >= j - 1 || i % divide == 0) {
				GLatLng point = (GLatLng) points.get(i);
				re.append(point.toString());
				re.append(",");

				count++;
			}
		}

		re.deleteCharAt(re.length() - 1);
		re.append("]");

		System.out.println("path count=" + count);

		return re.toString();
	}

	public String getPathPoints() {
		StringBuffer re = new StringBuffer();
		for (int i = 0, j = points.size(); i < j; i++) {
			GLatLng point = (GLatLng) points.get(i);
			re.append(point.toString());
			re.append(",");
		}

		re.deleteCharAt(re.length() - 1);

		return re.toString();
	}


}
